package com.iacrqq.sedaf.demo.sHttpServer.event;

import java.net.Socket;
import java.nio.channels.SocketChannel;

import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpServerConnection;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;

import com.iacrqq.sedaf.event.Event;

public class HttpEvent implements Event
{
	
	private int state;
	private SocketChannel channel;
	HttpServerConnection httpServerConnection;
	private HttpRequest httpRequest;
	HttpResponse httpResponse;
	private HttpContext httpContext = new BasicHttpContext(null);
	private HttpException httpException = null;
	
	@Override
	public void setState(int state)
	{
		this.state = state;
	}

	@Override
	public int getState() {
		return this.state;
	}
	
	public HttpEvent(int state, SocketChannel channel)
	{
		this.state = state;
		this.channel = channel;
	}
	
	public HttpServerConnection getHttpServerConnection()
	{
		return httpServerConnection;
	}

	public void setHttpServerConnection(HttpServerConnection httpServerConnection)
	{
		this.httpServerConnection = httpServerConnection;
	}
	
	public Socket getSocket()
	{
		return channel.socket();
	}
	
	public HttpRequest getHttpRequest()
	{
		return httpRequest;
	}

	public void setHttpRequest(HttpRequest httpRequest)
	{
		this.httpRequest = httpRequest;
	}
	
	public HttpResponse getHttpResponse()
	{
		return httpResponse;
	}

	public void setHttpResponse(HttpResponse httpResponse)
	{
		this.httpResponse = httpResponse;
	}
	
	public HttpContext getHttpContext()
	{
		return httpContext;
	}

	public void setHttpContext(HttpContext httpContext)
	{
		this.httpContext = httpContext;
	}
	
	public HttpException getHttpException()
	{
		return httpException;
	}

	public void setHttpException(HttpException httpException)
	{
		this.httpException = httpException;
	}

	
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		sb.append("envent:{state:");
		sb.append(state);
		sb.append("}");
		
		return sb.toString();
	}
}
